package com.xuyuan.agent.util;

import com.xuyuan.agent.intro.OrderService;
import com.xuyuan.agent.intro.OrderServiceImpl;

public class ProxyTest {
    public static void main(String[] args) {
        StackTraceElement[] stackTrace = new RuntimeException().getStackTrace();
        for (StackTraceElement stackTraceElement : stackTrace) {
            if (stackTraceElement.getMethodName().equals("main")) {
                System.out.println(stackTraceElement.getClassName());
            }
        }

        Object cglibProxyObject = ProxyUtil.getCglibProxyObject(OrderServiceImpl.class);
        OrderService orderService1 = (OrderService) cglibProxyObject;
        orderService1.save();

        Object jdkProxyDynamic = ProxyUtil.getJDKProxyObject(OrderServiceImpl.class);
        OrderService orderService = (OrderService) jdkProxyDynamic;
        orderService.save();

    }
}
